/*
 * ImagenDelegate.java
 *
 * Created on 26 de septiembre de 2006, 10:07 AM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package com.src.computec.radar.imagen.delegate;

import com.src.computec.radar.base.delegate.BaseDelegate;
import com.src.computec.radar.base.servicelocator.exception.ServiceLocatorException;
import com.src.computec.radar.imagen.base.constantes.ConstantesGenerales;
import com.src.computec.radar.imagen.dto.ImagenDto;
import com.src.computec.radar.imagen.exception.ImagenException;
import com.src.computec.radar.imagen.session.ImagenSessionRemote;
import com.src.computec.radar.imagen.session.ImagenSessionRemoteHome;
import java.rmi.RemoteException;
import java.util.List;
import javax.ejb.CreateException;

/**
 *
 * @author andresoc
 */
public class ImagenDelegate extends BaseDelegate {
    
    ImagenSessionRemoteHome imagenSessionRemoteHome = null;
    ImagenSessionRemote imagenSessionRemote = null;
    
    /** Creates a new instance of ImagenDelegate */
    public ImagenDelegate() throws ImagenException {
        try {
            imagenSessionRemoteHome = (ImagenSessionRemoteHome) this.getHome(ConstantesGenerales.getInstance().JNDINAME_IMAGENSESSION, ImagenSessionRemoteHome.class);
            imagenSessionRemote = imagenSessionRemoteHome.create();
        }
        catch(ServiceLocatorException ex){
            throw new ImagenException("ImagenDelegate:ImagenDelegate: " + ex.getMessage(), ex);
        }
        catch(CreateException ex) {
            throw new ImagenException("ImagenDelegate:ImagenDelegate: " + ex.getMessage(), ex);
        }
        catch(RemoteException ex){
            throw new ImagenException("ImagenDelegate:ImagenDelegate: " + ex.getMessage(), ex);
        }
    }
    
    public void copiarImagenGuiaDistribucion(ImagenDto dto) throws ImagenException {
        try {
            imagenSessionRemote.copiarImagenGuiaDistribucion(dto);
        }
        catch(RemoteException e) {
            throw new ImagenException("ImagenDelegate:copiarImagenGuiaDistribucion: " + e.getMessage(), e);
        }
    }
    
    public boolean existeImagenGuiaDistribucion(ImagenDto dto) throws ImagenException {
        try {
            return imagenSessionRemote.existeImagenGuiaDistribucion(dto);
        }
        catch(RemoteException e) {
            throw new ImagenException("ImagenDelegate:existeImagenGuiaDistribucion: " + e.getMessage(), e);
        }
    }
    
    public List getListNamesFilesByDirectory(ImagenDto dto) throws ImagenException {
        try {
            return imagenSessionRemote.getListNamesFilesByDirectory(dto);
        }
        catch(RemoteException e) {
            throw new ImagenException("ImagenDelegate:getListNamesFilesByDirectory: " + e.getMessage(), e);
        }
    }
    
    public void garbageCollectorImages() throws ImagenException {
        try {
            imagenSessionRemote.garbageCollectorImages();
        }
        catch(RemoteException e) {
            throw new ImagenException("ImagenDelegate:garbageCollectorImages: " + e.getMessage(), e);
        }
    }
}